﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace psafth.RCTiming.Main.Pages
{
    /// <summary>
    /// Interaction logic for SettingsDecoder.xaml
    /// </summary>
    public partial class SettingsDecoder : Page
    {
        public SettingsDecoder()
        {
            InitializeComponent();
            tbIpAddress.Text = Properties.Settings.Default.DecoderIPAddress;
            tbPort.Text = Properties.Settings.Default.DecoderTcpPort.ToString();
            cbSyncTime.IsChecked = Properties.Settings.Default.DecoderUseClockSync;
        }

        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            Views.AMBStatus t = new Views.AMBStatus();

            t.Show();
        }

        private void tbIpAddress_TextChanged(object sender, TextChangedEventArgs e)
        {
            Properties.Settings.Default.DecoderIPAddress = tbIpAddress.Text;
            Properties.Settings.Default.Save();
        }

        private void tbPort_TextChanged(object sender, TextChangedEventArgs e)
        {
            Properties.Settings.Default.DecoderTcpPort = Convert.ToInt32(tbPort.Text);
            Properties.Settings.Default.Save();
        }

        private void cbSyncTime_Checked(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.DecoderUseClockSync = (cbSyncTime.IsChecked.HasValue) ? cbSyncTime.IsChecked.Value : false;
            Properties.Settings.Default.Save();
        }
    }
}
